package com.xdf.ecommerce.constant;

/**
 * @author chanchaw
 * @create 2025-10-27 19:41
 */
public enum GoodsCategory {
    FOOD(0,"food","食品"),
    DRINK(1,"drink","饮料"),
    WINE(2,"wine","酒"),
    ELECT(3,"electronic","消费电子"),
    ;
    private int id;
    private String sid;
    private String remark;
    public int getId() {return id;}
    public String getSid() {return sid;}
    public String getRemark() {return remark;}

    GoodsCategory(int id,String sid, String remark) {
        this.id = id;
        this.sid = sid;
        this.remark = remark;
    }

    // 根据索引返回枚举值
    public static GoodsCategory of(int id){
        return ofid(id);
    }
    public static GoodsCategory ofid(int id){
        for(GoodsCategory item:GoodsCategory.values()){
            if(item.getId() == id) return item;
        }
        return null;
    }

    public static GoodsCategory ofsid(String sid){
        for(GoodsCategory item:GoodsCategory.values()){
            if(item.getSid().equals(sid)) return item;
        }
        return null;
    }
}
